Skip to content

perf(refit): batch MXFP8 expert prequantization - #3804

Draft
seonjinn wants to merge 104 commits into
NVIDIA-NeMo:mainfrom
seonjinn:sna/perf-mxfp8-batched-expert-prequantization
Draft

perf(refit): batch MXFP8 expert prequantization#3804
seonjinn wants to merge 104 commits into
NVIDIA-NeMo:mainfrom
seonjinn:sna/perf-mxfp8-batched-expert-prequantization

Conversation

@seonjinn

@seonjinn seonjinn commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Batch matching MoE expert weights before trainer-side MXFP8 prequantization. The path quantizes at most 16 experts per call, preserves the original refit wire order, and reuses temporary stacking storage only within one export pass.

Non-expert weights and expert groups that cannot be batched keep the existing per-tensor path. fp8_param=true is rejected because this path requires BF16 source weights.

This PR builds on #3294. Async NCCL Reshard receiver-side conversion is separate and is not changed here.

Why

The existing path launches one quantization operation per expert tensor. Large MoE models repeat this operation hundreds of times per refit. Batching compatible experts reduces launch and synchronization overhead without changing the value/scale payload consumed by vLLM.

Evidence

Prior Qwen3-30B-A3B prototype on GB200, synchronous colocated GRPO with CUDA Graph, 20 steps:

Metric Per expert Batched Change
Transfer/update 4.506 s 2.200 s -51.2%
Total refit 8.431 s 5.935 s -29.6%
E2E step 188.88 s 185.32 s -1.89%
Throughput 2,199.0 tok/s/GPU 2,243.0 tok/s/GPU +2.00%

Generation KL error was unchanged at 0.00398.

Current head cfbe773c70a61f55835e6ed15339c61e3ae844ed:

  • 48 relevant GB200 unit tests passed, including quantization parity, Bridge export order, bounded batching, split payloads, scale shape, CUDA stream handoffs, and recipe scope.
  • Ruff lint, format, and diff checks passed on all changed files.
  • Current-head 20-step performance A/B is running; the table above remains prototype evidence until that rerun completes.

Qwen3-235B peak-memory and end-to-end validation remain before this PR is ready for review.

seonjinn added 30 commits July 21, 2026 16:16
Reduce MXFP8 and ModelOpt refit overhead while preserving transport and checkpoint-engine lifecycle correctness.

Signed-off-by: sna <sna@nvidia.com>
Signed-off-by: sna <sna@nvidia.com>
Signed-off-by: sna <sna@nvidia.com>
Signed-off-by: sna <sna@nvidia.com>
Signed-off-by: sna <sna@nvidia.com>
Signed-off-by: sna <sna@nvidia.com>
Signed-off-by: sna <sna@nvidia.com>
…optimization-squashed

# Conflicts:
#	nemo_rl/algorithms/grpo.py
Signed-off-by: seonjinn <sna@nvidia.com>
Signed-off-by: seonjinn <sna@nvidia.com>
Signed-off-by: seonjinn <sna@nvidia.com>
Signed-off-by: seonjinn <sna@nvidia.com>
Signed-off-by: seonjinn <sna@nvidia.com>
…timization-squashed

Signed-off-by: seonjinn <sna@nvidia.com>
…optimization-squashed

Signed-off-by: seonjinn <sna@nvidia.com>
Signed-off-by: seonjinn <sna@nvidia.com>
…optimization-squashed

Signed-off-by: seonjinn <sna@nvidia.com>
…optimization-squashed

Signed-off-by: seonjinn <sna@nvidia.com>

# Conflicts:
#	nemo_rl/models/generation/vllm/quantization/fp8.py
#	tests/unit/models/generation/test_vllm_fp8_quantization.py
Signed-off-by: seonjinn <sna@nvidia.com>
Signed-off-by: seonjinn <sna@nvidia.com>
Signed-off-by: seonjinn <sna@nvidia.com>
Signed-off-by: seonjinn <sna@nvidia.com>
Signed-off-by: seonjinn <sna@nvidia.com>
Signed-off-by: seonjinn <sna@nvidia.com>
Signed-off-by: seonjinn <sna@nvidia.com>
@seonjinn

Copy link
Copy Markdown
Contributor Author

/ok to test 1c9e4b5

…60904

Signed-off-by: seonjinn <sna@nvidia.com>

# Conflicts:
#	nemo_rl/algorithms/grpo.py
#	nemo_rl/weight_sync/collective_weight_synchronizer.py
#	nemo_rl/weight_sync/interfaces.py
#	tests/unit/models/generation/test_vllm_fp8_quantization.py
Signed-off-by: seonjinn <sna@nvidia.com>
Signed-off-by: seonjinn <sna@nvidia.com>
Signed-off-by: seonjinn <sna@nvidia.com>
Signed-off-by: seonjinn <sna@nvidia.com>
Signed-off-by: seonjinn <sna@nvidia.com>
Signed-off-by: seonjinn <sna@nvidia.com>
Signed-off-by: seonjinn <sna@nvidia.com>
Signed-off-by: seonjinn <sna@nvidia.com>
Signed-off-by: seonjinn <sna@nvidia.com>
Signed-off-by: seonjinn <sna@nvidia.com>
Signed-off-by: seonjinn <sna@nvidia.com>
Signed-off-by: seonjinn <sna@nvidia.com>
Signed-off-by: seonjinn <sna@nvidia.com>
Signed-off-by: seonjinn <sna@nvidia.com>
Signed-off-by: seonjinn <sna@nvidia.com>
Signed-off-by: seonjinn <sna@nvidia.com>
Signed-off-by: seonjinn <sna@nvidia.com>
Signed-off-by: seonjinn <sna@nvidia.com>
Signed-off-by: seonjinn <sna@nvidia.com>
Signed-off-by: seonjinn <sna@nvidia.com>
Signed-off-by: seonjinn <sna@nvidia.com>
Signed-off-by: seonjinn <sna@nvidia.com>
Signed-off-by: seonjinn <sna@nvidia.com>
Signed-off-by: seonjinn <sna@nvidia.com>
Use the replayed PR NVIDIA-NeMo#3804 tree on the latest PR NVIDIA-NeMo#3294 and main integration.

Signed-off-by: seonjinn <sna@nvidia.com>
@github-actions github-actions Bot removed the CI Relating to CI label Sep 5, 2026
@seonjinn

seonjinn commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

Self-review completed on head cfbe773c70a61f55835e6ed15339c61e3ae844ed.

Reviewed the six-file change on top of #3294, including numerical behavior, refit wire order, CUDA stream handoffs, temporary-buffer lifetime, configuration guards, and fallback paths. No blocking correctness, compatibility, security, or deadlock issue was found.

Key checks:

  • The batched iterator preserves the exact Bridge export order. This is required because the collective sender transfers tensors without parameter names.
  • Each quantization call is bounded to 16 compatible experts; incompatible or non-expert tensors keep the per-tensor path.
  • Split value/scale batches and singleton scale dimensions retain the existing vLLM payload contract.
  • Active fp8_param=true is rejected because trainer-side prequantization requires BF16 source weights. A stale fp8_param=true value is ignored when FP8 is disabled.
  • Producer/consumer CUDA stream edges and temporary scratch lifetime have direct regression coverage.

Validation on GB200:

  • 48 passed, 29 deselected in the relevant vLLM/MXFP8 unit-test selection.
  • The focused source-order, bounded-batch, scale-parity, and stream-handoff selection passed 9/9.
  • Ruff lint, format, and git diff --check passed for all changed files.
  • All commits are signed off; GitHub DCO, title, copyright, secrets, and submodule checks pass.

The current-head Qwen3-30B-A3B 20-step performance A/B and Qwen3-235B peak-memory validation are still pending, so the PR remains a draft.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI:L0 Run doctests and unit tests Documentation Improvements or additions to documentation Low Precision Performance Related to improving performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant